﻿using Bigway.Common;
using Bigway.Common.Jobs;

namespace Benefactor.Jobs;

public class JobRegistry: BaseJobRegistry
{
    public JobRegistry(IServiceScopeFactory serviceScopeFactory)
    {
        NonReentrantAsDefault();

        const string systemId = SystemIds.GiftPiker;

        ScheduleBackgroundJob(
            new CalculateAndGenerateRefererFeeJob(
                serviceScopeFactory, 
                systemId),
            schedule => schedule
                .ToRunEvery(1)
                .Days()
                .At(15, 30) // 15:30 UTC equals 23:30 China time
            );

        ScheduleBackgroundJob(new GenerateVouchersJob(
            serviceScopeFactory,
            systemId),
            schedule => schedule
                .ToRunNow()
                .AndEvery(1)
                .Days()
                .At(15, 45)
            );

        ScheduleBackgroundJob(new BenefitsCardOrderProcessJob(
                serviceScopeFactory,
                systemId),
            schedule => schedule
                .ToRunNow()
                .AndEvery(1)
                .Days()
                .At(15, 50)
        );

        ScheduleBackgroundJob(new DailyDatabaseBackupJob(
                serviceScopeFactory,
                systemId),
            schedule => schedule
                .ToRunEvery(1)
                .Days().At(15, 55)
        );
    }
}